`
https://leetcode.cn/problems/house-robber/
`

/**
 * @param {number[]} nums
 * @return {number}
 */
var rob = function (nums) {
  const memo = new Array(nums.length).fill(-1)

  function dp(i) {
    if (i >= nums.length) {
      return 0
    }

    if (memo[i] !== -1) {
      return memo[i]
    }

    memo[i] = Math.max(
      // 抢这家
      nums[i] + dp(i + 2),
      // 不抢这家
      dp(i + 1)
    )

    return memo[i]
  }

  return dp(0)
};